<template>
    <el-row class="aside-box">
        <el-aside :class="{'width220': sub_menu_show === true}">
            <el-row class="carte-info">

                <el-row class="carte-content">
                    <el-row class="carte">
                        <el-collapse accordion>
                            <div v-for="item in menu" class="title-img" :key="item.id" :class="{'word-color':item.id === menu_id}" @click="changeMenu(item.id, 0)">
                                <el-tooltip class="item" effect="dark" :content="item.title" placement="right">
                                    <el-button >
                                        <img v-if="item.id === menu_id" :src="item.highlight_icon"/>
                                        <img v-else :src="item.icon"/>
                                    </el-button>
                                </el-tooltip>
                            </div>
                        </el-collapse>
                    </el-row>
                    <el-row class="menu" v-show="sub_menu_show" :style="{height: inner_height + 'px'}">
                        <ul>
                            <li v-for="item in sub_menu" :key="item.id" @click="changeSubMenu(item.id)" :class="{'menu-cur':item.id === sub_menu_id}" >
                                <router-link v-if="item.id==13005?false:true" :to="item.link">{{item.title}}</router-link>
                                <el-row v-if="item.id==13005?false:true" class="line"></el-row>
                            </li>
                        </ul>
                    </el-row>
                </el-row>

                <el-row class="carte-empty"></el-row>

            </el-row>

        </el-aside>
    </el-row>

</template>
<script type="text/ecmascript-6">


    export default{
        data() {
            return {
                inner_height: 0,
                menu: [],
                menu_id: 0,
                sub_menu_id: 0,
                sub_menu_temp: {},
                sub_menu: [],
                sub_menu_show: false,
                default_path_use: 0
            }
        },
        mounted () {
            this.inner_height = window.innerHeight - 60;
            this.menu = window.menu;
            this.sub_menu_temp = window.sub_menu;
            this.changeMenu(window.menu_id, window.sub_menu_id);
            this.$router.push(window.default_path);
            this.default_path_use = 1;
        },
        methods: {
            changeMenu(id, sub_menu_id) {
                this.menu_id = id;
                if (this.sub_menu_temp[id]) {
                    this.sub_menu = this.sub_menu_temp[id];
                    if (this.sub_menu.length === 1) {
                        this.sub_menu_show = false;
                    } else {
                        this.sub_menu_show = true;
                    }
                    if (sub_menu_id === 0) {
                        sub_menu_id = this.sub_menu[0].id;
                    }
                    this.changeSubMenu(sub_menu_id);
                } else {
                    this.sub_menu_show = false;
                }
            },
            changeSubMenu(id) {
                let _this = this;
                _this.sub_menu_id = id;
                if (_this.default_path_use) {
                    _this.sub_menu.forEach(function (menu) {
                        if (menu.id === id) {
                            _this.$router.push(menu.link);
                        }
                    });
                }
            },
        }
    }
</script>

<style lang="scss" type="text/scss">
   // @import '~Sass/variables';
    .carte-info .carte-content{
        position: fixed;
        left: 0;
        top:60px;
        height: 100%;
        background: #fff;
        z-index: 1000;
    }
    .carte-info .carte-empty{
        width: 70px;
        height: 100%;
    }
    .el-aside {
        width: 71px !important;
        background: #fff;
        overflow: hidden;
    }
    .width220{
        width: 221px !important;
    }
    .carte-info .menu{
        overflow: hidden;
    }
    .el-menu{
        border: none;
    }
    .el-menu img{
        margin-right: 10px
    }
    .el-submenu__title{
        height: 60px;
        line-height: 60px;
        padding-left: 11px !important
    }
    .el-submenu.is-active, .el-submenu.is-active .el-menu-item{
        background: #111
    }
    .el-submenu__title:hover, .el-menu-item:focus, .el-menu-item:hover{
        background: none
    }
    .el-submenu__title, .el-menu-item{
        color: #fff
    }
    .el-menu-item{
        height: 40px;
        line-height: 40px;
    }
    .el-menu-item.level{
        padding-left: 11px !important
    }
    .el-menu-item.is-active a{
        color: #01a2fd;
    }
    .el-menu-item a{
        color: #fff;
    }
    
    .aside-box .el-collapse-item__arrow{
        display:none;
    }
    .aside-box .el-collapse{
        border-top:none;
        border-bottom:none;
    }
    .aside-box .el-collapse-item__header,.aside-box .el-collapse-item__wrap{
        border-bottom:none;
    }
    .title-img{
        width: 70px;
        box-sizing: border-box;
        position: relative;

        .el-button{
            border: none;
            padding: 16px 0;
            height: 60px;
            width: 100%;
        }
        .el-button:active{
            background: #fff;
        }
        .el-button:hover{
            background: #fff;
        }
    }
    .title-img a{
        height: 60px;
        width: 70px;
        display: block;
        position: absolute;
        top:0;
        left: 0;
    }
    .title-img img{
        width: 28px;
        height: 28px;
        display: block;
        margin: 0 auto;
    }
    .aside-box .el-collapse{
        overflow-y: auto;
        height: 100%;
        margin-right: -17px;
    }
    .menu ul li{
        position: relative;
        height: 54px;
        line-height: 54px;
        font-size: 14px;
        -webkit-transition: all 0.3s;
        -moz-transition: all 0.3s;
        -ms-transition: all 0.3s;
        -o-transition: all 0.3s;
        transition: all 0.3s;
    }
    .menu ul li a {
        display: block;
        width: 100%;
        height: 100%;
        padding-left: 22px;
        text-decoration: none;
        -webkit-box-sizing: border-box;
        -moz-box-sizing: border-box;
        box-sizing: border-box;
    }
    .menu ul li .line {
        display: none;
        position: absolute;
        top: 0;
        left: -9px;
        width: 20px;
        height: 100%;
        background: url("//ws-1253783305.cossh.myqcloud.com/es/backend/v1/line-right.png") center center no-repeat;
    }
    .menu ul li.menu-cur .line{
        display: block;
    }
    .menu ul li.menu-cur a {
        color: #437eff;
        background: #f2f7fa;
    }
    .menu{
        -webkit-transition: all 0.3s;
        -moz-transition: all 0.3s;
        -ms-transition: all 0.3s;
        -o-transition: all 0.3s;
        transition: all 0.3s;
        width: 150px;
        overflow: hidden;
    }
    .menu.slideint {
        width: 150px;
    }
    .menu ul{
        height: 100%;
        overflow-y:auto;
        margin-right: -17px;
    }
    .aside-box .el-collapse-item__content{
        position: absolute;
        left: 70px;
        top: 70px;
        width: 150px;
        z-index: 100;
        padding-bottom:0;
    }
    .carte,.menu{
        float: left;
    }
    .carte{
        border-right: 1px solid #d5d5d5;
        width:71px;
        height: 100%;
        overflow: hidden;
    }
    .center{
        text-align: center;
    }

    .el-popper .entry{
        background: #f9f8f7;
        width: 100%;
        position: absolute;
        top: 0;
        left: 0;
        padding: 10px 20px 5px;

    }
    .el-popper .entry .el-row{
        text-align: center;
    }
    .personal-popper {
        padding:0;
        .el-row{
            line-height: 24px;
        }
        .entry2{
            padding-top: 60px;
            .el-row{
                text-align: center;
                padding: 8px 5px 8px 0;
            }
            .el-row:hover{
                background: #ecf2ff;
                cursor: pointer;
                color: #6996ff;
            }
            .el-row:hover a{
                color: #6996ff;
                cursor: pointer;
            }
        }
    }
    .account-dialog {
        .el-dialog{
            width:45%;
            .el-dialog__header{
                padding:10px 20px;
            }
            .el-dialog__body{
                padding:15px 0 30px 0;
                .el-col-15{
                    margin-left: 60px;
                }
                .el-radio-group{
                    margin-left: 60px;
                }
                .el-upload{
                    margin-left: 60px;
                }
                .el-form-item{
                    margin-bottom: 10px;
                    .el-form-item__error{
                        margin-left: 60px;
                    }
                }
                .el-upload-list{
                    margin-left:60px;
                    width:77%;
                }
                .sure{
                    margin: 20px 0 0 480px;
                }
            }
        }

    }
    .password-dialog{
        .el-dialog{
            width:35%;

            .el-input{
                width:87%;
            }
            .el-button{
                margin-left:85%;
            }
            .el-dialog__body {
                padding: 15px 20px 20px 20px;
            }
        }
    }
</style>

